// pages/user_record/user_record.js
var app = getApp();
const $ = require('../../utils/utils');
const config = require('../../config');
Page({

    /**
     * 页面的初始数据
     */
    data: {
        recordList: [],
        pagesize: 10,
        pageno: 1,
        hasMoreData: true,
        user_deposit_status: ''
    },


    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this.userRecord();
    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {
        var that = this;
        if (that.data.hasMoreData) {
            that.setData({
                pageno: that.data.pageno + 1
            })
            that.userRecord();
        } else {
            wx.showToast({
                title: '没有更多数据',
            });
            setTimeout(function () {
                wx.hideToast();
            }, 2000);
        }
    },

    //展示用户记录信息
    userRecord: function () {
        var that = this;
        let data = {
            pagesize: that.data.pagesize,
            pageno: that.data.pageno,
            userid: wx.getStorageSync('userid'),
            usertoken: wx.getStorageSync('usertoken')
        }
        let url = $.getUrl(config.getExpenseRecord,data)
        $.get(url).then(data=>{
            var contentlistTem = that.data.recordList;
            var contentlist = data.items;
            if (contentlist.length < that.data.pagesize) {
                that.setData({
                    recordList: contentlistTem.concat(contentlist),
                    hasMoreData: false
                })
            } else {
                that.setData({
                    recordList: contentlistTem.concat(contentlist),
                    hasMoreData: true,
                });
            }
        })

    },


})